package com.hunttown.mes.dao;

import com.hunttown.common.dao.base.BaseDao;
import com.hunttown.common.domain.Query;
import com.hunttown.mes.domain.WorkflowApplyLineUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * created by wangjunfu on 2020-12-24 09:18:12
 */
@Repository
public class WorkflowApplyLineUserDao extends BaseDao {
    private static final Logger logger = LoggerFactory.getLogger(WorkflowApplyLineUserDao.class);

    public WorkflowApplyLineUser insert(final WorkflowApplyLineUser workflowApplyLineUser) {
        insert("WorkflowApplyLineUser.insert", workflowApplyLineUser);
        return workflowApplyLineUser;
    }

    public Boolean updateInfoById(final WorkflowApplyLineUser workflowApplyLineUser) {
        return update("WorkflowApplyLineUser.updateInfoById", workflowApplyLineUser) > 0;
    }

    public Boolean updateInfoByQuery(final Query query) {
        return update("WorkflowApplyLineUser.updateInfoByQuery", query) > 0;
    }

    public WorkflowApplyLineUser selectById(final Integer id) {
        Query query = Query.noPage();
        query.put("id", id);
        return queryForObject("WorkflowApplyLineUser.selectById", query);
    }

    public List<WorkflowApplyLineUser> selectByQuery(final Query query) {
        return queryForList("WorkflowApplyLineUser.selectByQuery", query);
    }

    public Long countByQuery(final Query query) {
        return queryForObject("WorkflowApplyLineUser.countByQuery", query);
    }

    public Boolean deleteById(final Integer id) {
        WorkflowApplyLineUser workflowApplyLineUser = new WorkflowApplyLineUser();
        workflowApplyLineUser.setDeleteFlag(1);
        workflowApplyLineUser.setId(id);

        return update("WorkflowApplyLineUser.updateInfoById", workflowApplyLineUser) > 0;
    }

    //物理删除不可恢复，慎用！
    public Boolean deleteByIdForPhysical(final Integer id) {
        Query query = Query.noPage();
        query.put("id", id);
        return delete("WorkflowApplyLineUser.deleteById", query) > 0;
    }
}